<?php

/*
  +--------------------------------------------------------------------------
  |   Invision Power Board
  |   =============================================
  |   by Matthew Mecham
  |   (c) 2001 - 2006 Invision Power Services, Inc.
  |
  |   =============================================
  |
  |
  +---------------------------------------------------------------------------
  |   > $Date: 2007-05-02 17:29:12 -0400 (Wed, 02 May 2007) $
  |   > $Revision: 959 $
  |   > $Author: BabyWolf $
  +---------------------------------------------------------------------------
  |
  |   > Access the dkm_bank files
  |   > Module written by BabyWolf
  |   > Date started: 07th February 2009
  |
  |	> Module Version Number: 1.0.0
  |   > DBA Checked: Sat 07 Feb 2009
  |   > Quality Checked: Sat 07 Feb. 2009
  +--------------------------------------------------------------------------
 */


if (!defined('IN_IPB')) {
    print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
    exit();
}

class film {
    # Classes
    var $act;
    var $hotPerPage;
    var $defaultPerPage;
    var $pathway;
    var $code;
    var $ipsclass;

    # Others
    var $output = "";
    var $page_title = "";
    var $nav = array();
    var $page = "";
    var $html = "";
    var $attach_pids = array();
    var $carts = array();
    var $class_attach;
    var $recent_topic;
    var $statfunc = "";
    var $catName = array();
    var $navigations = array();
    var $common;

    // Auto run
    /* ------------------------------------------------------------------------- */

    function auto_run() {
        //-----------------------------------------
        // Require the HTML and language modules
        //-----------------------------------------
        
        $this->init();
        $this->base_url = $this->ipsclass->vars['default_url'];
        $default_url = $this->ipsclass->vars['board_url'];
        $this->base_url_nosess = "{$this->ipsclass->vars['board_url']}/index.{$this->ipsclass->vars['php_ext']}";
        if(intval($this->ipsclass->member['id']) > 0 ){
            $default_url = $this->ipsclass->vars['profile_url'];
        }else{
            $default_url = $this->ipsclass->vars['board_url'];
        }
        //INITs class attach
        require_once( ROOT_PATH . 'sources/classes/attach/class_attach.php' );
        $this->class_attach = new class_attach();
        $this->class_attach->ipsclass = & $this->ipsclass;
        $this->class_attach->attach_post_key = '';
        $this->class_attach->attach_post_key = '';
        $this->class_attach->type = 'post';
        $this->class_attach->init();
        require_once( ROOT_PATH . "sources/portal_plugins/recent_topics.php" );
        $this->recent_topic = new ppi_recent_topics();
        $this->recent_topic->ipsclass =& $this->ipsclass;
        if (USE_MODULES == 1) {
            require ROOT_PATH . "modules/ipb_member_sync.php";
            $this->modules = new ipb_member_sync();
            $this->modules->ipsclass = & $this->ipsclass;
            
        }
        //echo $this->ipsclass->vars['all_product_cat_id'];exit();
        require_once( ROOT_PATH . 'sources/action_public/Common.php' );
        $this->common = new Common();
        $this->common->ipsclass = & $this->ipsclass;
        $this->common->profile_url = $this->ipsclass->vars['profile_url'];
        $this->common->parseLastVisit();
        
        require_once( ROOT_PATH . 'sources/action_public/FilmAction.php' );
        $this->filmAction = new FilmAction();
        $this->filmAction->ipsclass = & $this->ipsclass;
        $this->filmAction->film_url = $this->ipsclass->vars['film_url'];
        $this->filmAction->common = $this->common;
        switch ($this->ipsclass->input['CODE']) {
            default :
                $this->showDefaultPage();
                break;
        }
        $this->ipsclass->print->add_output($this->output);
        $this->ipsclass->print->do_output(array('TITLE' => $this->page_title, 
                                                'JS' => 1, 
                                                'NAV' => '',
                                                'NAVI' => $this->navigations,
                                                'PAGE'=>$this->page));        
    }
   
    /*
     * start load module
     */
    
    function loadNewsModule($type, $start = "", $perPage = "", $loadNews = FALSE, $loadVideo = FALSE, $isNew = FALSE, $loadAllImage = FALSE, $all_parent = -1){
        //echo $type;exit();
        $where = "";
        if(intval($type) <= 0 && !$loadVideo){
            return null;
        }
        if(intval($start) < 0 ){
            $start = 0;
        }
        if($perPage <= 0){
            $perPage = $this->defaultPerPage;
        }
        //echo $all_parent;
        if($all_parent > 0){
            $childs = array();
            $this->ipsclass->DB->build_query( array('select' => 'f.id, f.name',
                                                'from'   => 'forums f',
                                                'where'    => "f.parent_id = {$all_parent}"
                                                ) 
                                        );
            $this->ipsclass->DB->exec_query();
            while($row = $this->ipsclass->DB->fetch_row()){
                $childs[] = $row['id'];
            }
            if(count($childs) <= 0){
                return null;
            }
            $str = implode(",", $childs);
            $where = "t.forum_id IN ( {$str}) and t.approved = 1  order by t.tid DESC";
            //echo $where;
           
        }else{
            $where = "t.forum_id = " . intval($type)  . " and t.approved = 1 ";
        }
        
        
        $this->ipsclass->DB->build_query( array('select' => 'count(t.tid) as count',
                                                'from'   => 'topics t',
                                                'where'    => $where
                                                ) 
                                        );
        $this->ipsclass->DB->exec_query();
        $totalId = $this->ipsclass->DB->fetch_row();
        //var_dump($totalId);exit();
        if($totalId['count'] <= 0){
            return null;
        }
        $this->ipsclass->DB->flush_query();
        $this->ipsclass->DB->build_query( array( 'select'   => 't.*',
                                                 'from'     => array( 'topics' => 't' ),
                                                 'where'    => $where . "",
                                                 'limit'         => array($start, $perPage),
                                                 'add_join' => array(0 => array(
                                                                                 'select'=>'p.*',
                                                                                 'from'   => array( 'posts' => 'p' ),
                                                                                 'where'    => 'p.topic_id = t.tid',
                                                                                 'type'   => 'left'
                                                                                ),
                                                                      1 => array( 'select' => 'f.*',
                                                                                      'from'   => array( 'forums' => 'f' ),
                                                                                      'where'  => 'f.id=t.forum_id',
                                                                                      'type'   => 'left' ),
                                                                         2 => array( 'select' => 'pro.*',
                                                                                      'from'   => array( 'product_info' => 'pro' ),
                                                                                      'where'  => 'pro.product_id = t.tid',
                                                                                      'type'   => 'left' )
                                                 )
                                            )
                                        );
        $this->ipsclass->DB->exec_query();
        //$att_new_id = array();
        $temps = array();
        while($row = $this->ipsclass->DB->fetch_row()){
            $row['rewrite_name'] = $this->common->filter_title($row['name']);
            $row['rewrite_title'] = $this->common->filter_title($row['title']);
            $row['rewrite_date'] = date("{$this->ipsclass->lang['seoDateFormat']}", $row['post_date']);
            $row['org_price'] = number_format($row['org_price']);
            $row['price'] = number_format($row['price']);
            $temps[] = $row;
        }
        //var_dump($temps);exit();
        $datas_temp = array();

        foreach ($temps as $row) {

            $firstAttachments = $this->common->get_first_attachment($row['pid']);
            if(is_array($firstAttachments)){
                $row['first_attach'] = $firstAttachments;
            }
            if($loadAllImage){
                $images = $this->common->get_all_image($row['post']);
                $attaches = $this->common->get_all_attachment($row['pid']);
                if(is_array($images) && is_array($attaches)){
                    $images = array_merge($images, $attaches);
                    $row['total_images'] = $images;
                }
            }
            $row = $this->common->format_image_urls($row);
            $row['post'] = preg_replace("#\[attachment=(\d+?)\:(?:[^\]]+?)\]#is","",$row['post']); 
            $row['post'] = $this->recent_topic->Bw_CutString($row['post'], $loadNews ? 120 : 900);
            if($type != "-1"){
                $row['title'] = $this->recent_topic->Bw_CutString($row['title'], 38);
            }

            $row['description'] = $this->recent_topic->Bw_CutString($row['description'], 38);
            //$att_new_id[] = $row['pid'];          
            $datas_temp[] = $row;
			
        }
        unset ($temps);
        $datas = array();
        //var_dump($loadNews) ;exit();
        if($loadNews){
            $page = $this->ipsclass->buildMyPageLinks( array(  'TOTAL_POSS'  => $totalId['count'],
                                                           'PER_PAGE'    => $perPage,
                                                           'CUR_ST_VAL'  => $start,
                                                           'L_SINGLE'    => "",
                                                           'L_MULTI'     => $this->ipsclass->lang['tpl_pages'],
                                                           'BASE_URL'    => "#"
                                                        )
                                                    );
                                                    //var_dump($page);exit();
            $datas['page'] = $page;
        }
        
        //echo $type;
        $datas['type'] = $type;
        $datas['totalData'] = count($datas_temp);
        $datas['datas'] = $datas_temp;
        //var_dump($datas);exit();
        unset ($att_new_id);
        return $datas;

    }
    function loadSubStaticTextModule($mo=array(), $types, $tid, $length){
        $where = " t.forum_id = f.id and f.id = " . intval($types) . "   and t.tid = {$tid} ";
        $page = array();
        $this->ipsclass->DB->build_query( array( 'select'   => 't.*',
                                                 'from'     => array( 'topics' => 't' ),
                                                 'where'    => $where . "  group by concat(t.tid) order by t.tid DESC",
                                                 'limit'         => array(0, 1),
                                                 'add_join' => array(0 => array(
                                                                                 'select'=>'p.*',
                                                                                 'from'   => array( 'posts' => 'p' ),
                                                                                 'where'    => 'p.topic_id = t.tid',
                                                                                 'type'   => 'left'
                                                                                ),
                                                                      1 => array( 'select' => 'f.*',
                                                                                      'from'   => array( 'forums' => 'f' ),
                                                                                      'where'  => 'f.id=t.forum_id',
                                                                                      'type'   => 'left' ))
                                                )

            );
        $this->ipsclass->DB->exec_query();
        $module = $this->ipsclass->DB->fetch_row();
        
        $temp = $this->class_attach->render_attachments($module['post'], $this->attach_pids);
        $temp = preg_replace("#\[attachment =(\d+?)\:(?:[^\]]+?)\]#is","",$temp); 
        $temp = preg_replace("#\[attachment*\]#is","",$temp); 
        $module['post'] = $this->recent_topic->Bw_CutString($temp, 500);
        
        if ($module['topic_hasattach']) {
            $module['post'] = $this->class_attach->render_attachments($module['post'], $this->attach_pids);
        }
        if($tid == $this->ipsclass->vars['recruitment_id']){
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoRecruitmentPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $link = "<a href = '{$this->ipsclass->vars['default_url']}' alt='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}' title='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}'>{$this->ipsclass->lang['site_title']}</a> &raquo; <span>".$this->ipsclass->lang['new_recruitment_title'] ."</span>";
        }else if($tid == $this->ipsclass->vars['about_id']){
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoAboutPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $link = "<a href = '{$this->ipsclass->vars['default_url']}' alt='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}' title='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}'>{$this->ipsclass->lang['site_title']}</a> &raquo; <span>".$this->ipsclass->lang['about_title'] ."</span>";
        $this->nav = array($this->ipsclass->lang['about_title']);
        }else if($tid == $this->ipsclass->vars['id_services_news']){
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoServicePage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $link = "<a href = '{$this->ipsclass->vars['default_url']}' alt='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}' title='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}'>{$this->ipsclass->lang['site_title']}</a> &raquo; <span>".$this->ipsclass->lang['services_title'] ."</span>";
        $this->nav = array($this->ipsclass->lang['services_title']);
        }
        $module['headerTitle'] = $mo['headerTitle'];
        $module['pageName'] = $mo['pageName'];
        $module['cssClass'] = $mo['cssClass'];
        
        return $this->ipsclass->compiled_templates['skin_film']-> show_sub_static_module($module);
        unset ($var);
    }
    
    function loadRelatedModule($type, $tid = ""){
        $type = intval($type);
        $tid = intval($tid);
        $where = "";
        if(intval($tid) > 0){
            $where = "t.forum_id = {$type} and t.tid <> {$tid} and t.approved = 1 group by concat(t.tid) order by t.tid DESC, at.attach_id ASC ";
        }else{
            $where = "t.forum_id = {$type} and t.approved = 1 group by concat(t.tid) order by t.tid DESC, at.attach_id ASC ";
        }  

        $this->ipsclass->DB->flush_query();
        $this->ipsclass->DB->build_query( array( 'select'   => 't.*',
                                                 'from'     => array( 'topics' => 't' ),
                                                 'where'    => $where . "",
                                                 'limit'         => array(0, 10),
                                                 'add_join' => array(0 => array(
                                                                                 'select'=>'p.*',
                                                                                 'from'   => array( 'posts' => 'p' ),
                                                                                 'where'    => 'p.topic_id = t.tid',
                                                                                 'type'   => 'left'
                                                                                ),
                                                                     1 => array( 'select' => 'f.*',
                                                                                  'from'   => array( 'forums' => 'f' ),
                                                                                  'where'  => 'f.id=t.forum_id',
                                                                                  'type'   => 'left' ),
                                                                     2 => array( 'select' => 'at.*',
                                                                                  'from'   => array( 'attachments' => 'at' ),
                                                                                  'where'  => 'at.attach_rel_id=p.pid ',
                                                                                  'limit'  => array(0,1),
                                                                                  'type'   => 'left' )
                                                     )
                                                )

            );
        $this->ipsclass->DB->exec_query();
        $datas = array();
        $temps = array();
        while($row = $this->ipsclass->DB->fetch_row()){
            $row['rewrite_title'] = $this->common->filter_title($row['title']);
            $row['rewrite_date'] = date("{$this->ipsclass->lang['seoDateFormat']}", $row['post_date']);
            $temps[] = $row;
        }
        $datas['totalData'] = count($temps);
        $datas['datas'] = $temps;
        return $datas;
    }
    function loadMediaScrollerModule($type, $start = "", $perPage = "", $loadVideo = FALSE){
        if(intval($type) <= 0 && !$loadVideo){
            return null;
        }
        if(intval($start) < 0 ){
            $start = 0;
        }
        if($perPage <= 0){
            //$perPage = $this->defaultPerPage;
            $perPage = 5;
        }
        if($loadVideo){
            $perPage = 5;
        }
        $module = $this->loadNewsModule($type, $start, $perPage, TRUE, FALSE, FALSE, TRUE);
        //var_dump($module);exit();
        $module['pageName'] = "{$this->ipsclass->lang['seoGalleryPage']}{$this->ipsclass->lang['seoPageSuffix']}";
        $module['cssClass'] = "gallery";
        $module['mediaType'] = "gallery";
        $module['headerTitle'] = $this->ipsclass->lang['galaries_title'];
        //echo $this->ipsclass->compiled_templates['skin_film']->show_mediascroller_module($module);;exit();
        return $this->ipsclass->compiled_templates['skin_film']->show_mediascroller_module($module);
    }
    function loadMenuServiceModule(){
        $module = array();
        return $this->ipsclass->compiled_templates['skin_film']->load_menu_service_module($module);
    }
    
    function loadAdvertisingModule(){
        $files = $this->common->read_dir($this->ipsclass->vars['flash_diectory_path']."social/");       
        $module['random_flash_path_module'] = "/flash/social/";
        $module['random_flash_file_module'] = $files[array_rand($files)];
        unset ($files);
        return $this->ipsclass->compiled_templates['skin_film']->load_advertising_module($module);
    }
    function loadEventSlideModule($type, $start = 0, $perPage = 5){
        if(intval($type) <= 0 ){
            return null;
        }
        $module = $this->loadNewsModule($type, $start, $perPage, TRUE, FALSE, FALSE, TRUE);
        return $this->ipsclass->compiled_templates['skin_film']->load_event_slide_module($module);
    }
    
    
    /*
     * start load page
     */
    function showDefaultPage(){
        $filmCat = $this->filmAction->getCategories("vn");
        var_dump($filmCat);
        $this->output .= $this->ipsclass->compiled_templates['skin_film']->show_default_page($page);
        unset ($page);
        //$module['show_socialnews_module'] = "";
    }
    function showStaticTextPage($types, $tid){
        $where = " t.forum_id = f.id and f.id = " . intval($types) . "   and t.tid = {$tid} ";
        $page = array();
        $this->ipsclass->DB->build_query( array( 'select'   => 't.*',
                                                 'from'     => array( 'topics' => 't' ),
                                                 'where'    => $where . "  group by concat(t.tid) order by t.tid DESC",
                                                 'limit'         => array(0, 1),
                                                 'add_join' => array(0 => array(
                                                                                 'select'=>'p.*',
                                                                                 'from'   => array( 'posts' => 'p' ),
                                                                                 'where'    => 'p.topic_id = t.tid',
                                                                                 'type'   => 'left'
                                                                                ),
                                                                      1 => array( 'select' => 'f.*',
                                                                                      'from'   => array( 'forums' => 'f' ),
                                                                                      'where'  => 'f.id=t.forum_id',
                                                                                      'type'   => 'left' ))
                                                )

            );
        $this->ipsclass->DB->exec_query();
        $page = $this->ipsclass->DB->fetch_row();
        if ($page['topic_hasattach']) {
            $page['post'] = $this->class_attach->render_attachments($page['post'], $this->attach_pids);
        }
        if($tid == $this->ipsclass->vars['recruitment_id']){
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoRecruitmentPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $nav_path = "<a href = '{$this->ipsclass->vars['default_url']}' alt='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}' title='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}'>{$this->ipsclass->lang['site_title']}</a> &raquo; <span>".$this->ipsclass->lang['new_recruitment_title'] ."</span>";
            $this->page_title = $this->ipsclass->lang['new_recruitment_title'];
            $this->nav = array($this->ipsclass->lang['new_recruitment_title']);
        }else if($tid == $this->ipsclass->vars['about_id']){
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoAboutPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $nav_path = "<a href = '{$this->ipsclass->vars['default_url']}' alt='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}' title='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}'>{$this->ipsclass->lang['site_title']}</a> &raquo; <span>".$this->ipsclass->lang['about_title'] ."</span>";
            $this->page_title = $this->ipsclass->lang['about_title'];
            $this->nav = array($this->ipsclass->lang['about_title']);
        }else if($tid == $this->ipsclass->vars['contact_id']){
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoContactPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $nav_path = "<a href = '{$this->ipsclass->vars['default_url']}' alt='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}' title='{$this->ipsclass->lang['seoPumperPrefixTitle']}{$this->ipsclass->lang['film_title']}'>{$this->ipsclass->lang['site_title']}</a> &raquo; <span>".$this->ipsclass->lang['contact_title'] ."</span>";
            $this->page_title = $this->ipsclass->lang['contact_title'];
            $this->nav = array($this->ipsclass->lang['contact_title']);
        }
        $link = $nav_path;
        $page['pathWay']= $this->ipsclass->compiled_templates['skin_film']->load_pathway_module($link);
        $this->output .= $this->ipsclass->compiled_templates['skin_film']->show_static_page($page);
        $this->navigations = array('gt' => 'active');
        //unset ($var);
    }
    function showNewsPage($type){
        $start = intval($this->ipsclass->input['st']) >= 0 ? $this->ipsclass->input['st'] : 0 ;
        $perPage = $this->defaultPerPage;
        $page = $this->loadNewsModule($type, $start, $perPage, FALSE, FALSE, TRUE, TRUE);
        if($type == $this->ipsclass->vars['id_gnews']){
            $module_title= $this->ipsclass->lang['games_title'];
            $page['pageName'] = "{$this->ipsclass->lang['seoGameNewPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $page['seoPageName'] = $this->ipsclass->lang['seoGameNewPage'];
            $page['headerTitle'] = $this->ipsclass->lang['games_title'];
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoGameNewPage']}{$this->ipsclass->lang['seoPageSuffix']}";
        }else if($type == $this->ipsclass->vars['id_snews']){
            $module_title= $this->ipsclass->lang['socials_title'];
            $page['pageName'] = "{$this->ipsclass->lang['seoSocialNewPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $page['seoPageName'] = $this->ipsclass->lang['seoSocialNewPage'];
            $page['headerTitle'] = $this->ipsclass->lang['socials_title'];
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoSocialNewPage']}{$this->ipsclass->lang['seoPageSuffix']}";
        }else if($type == $this->ipsclass->vars['id_top_videos']){
            $module_title= $this->ipsclass->lang['video_title'];
            $page['pageName'] = "{$this->ipsclass->lang['seoVideoPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $page['seoPageName'] = $this->ipsclass->lang['seoVideoPage'];
            $page['headerTitle'] = $this->ipsclass->lang['video_title'];
            $current_path = $this->ipsclass->vars['film_url'] . "/$this->ipsclass->lang['seoVideoPage']}{$this->ipsclass->lang['seoPageSuffix']}";
        }else if($type == $this->ipsclass->vars['id_services_news']){
            $module_title= $this->ipsclass->lang['service_title'];//service_title
            $page['pageName'] = "{$this->ipsclass->lang['seoServicePage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $page['seoPageName'] = $this->ipsclass->lang['seoServicePage'];
            $page['headerTitle'] = $this->ipsclass->lang['service_title'];
            $current_path = $this->ipsclass->vars['film_url'] . "/{$this->ipsclass->lang['seoServicePage']}{$this->ipsclass->lang['seoPageSuffix']}";
        }else if($type == $this->ipsclass->vars['id_action_news']){
            $module_title= $this->ipsclass->lang['picture_activities_title'];
            $page['seoPageName'] = $this->ipsclass->lang['seoGalleryPage'];
            $page['headerTitle'] = $this->ipsclass->lang['service_title'];
            $current_path = "";
        }else if($type == $this->ipsclass->vars['id_enews']){
            $module_title= $this->ipsclass->lang['event_title'];
            $page['seoPageName'] = $this->ipsclass->lang['seoEventPage'];
            $page['headerTitle'] = $this->ipsclass->lang['event_title'];
            $current_path = "";
        }

        $link = "<a href = '{$this->ipsclass->vars['default_url']}' alt='{$this->ipsclass->lang["seoPumperfilmTitle"]}' title='{$this->ipsclass->lang["seoPumperfilmTitle"]}' >{$this->ipsclass->lang['film_title']}</a> &raquo; <span>{$module_title}</span>";;
        $page['pathWay'] = $this->ipsclass->compiled_templates['skin_film']->load_pathway_module($link);
        $this->output .=  $this->ipsclass->compiled_templates['skin_film']->skin_sub_page($page);
    }
    function showMediaPage($type){
        $start = intval($this->ipsclass->input['st']) >= 0 ? $this->ipsclass->input['st'] : 0 ;
        $perPage = $this->defaultPerPage;
        $page = array();
        $page['isVideo'] = FALSE;
        if($type == $this->ipsclass->vars['id_top_videos']){
            $page = $this->loadNewsModule(-2, $start, $perPage, FALSE, TRUE);
            $this->page = $this->ipsclass->lang['video_title'];
            $module_title = $this->ipsclass->lang['video_title'];
            $page['pageName'] = "{$this->ipsclass->lang['seoVideoPage']}{$this->ipsclass->lang['seoPageSuffix']}";
            $page['headerTitle'] = $this->ipsclass->lang['video_title'];
            $page['type'] = $this->ipsclass->vars['id_top_videos'];
        }
        $page['c'] = $this->code;
        $page['act'] = $this->act;
        $link = "<a href = '{$this->ipsclass->vars['default_url']}' alt='{$this->ipsclass->lang["seoPumperfilmTitle"]}' title='{$this->ipsclass->lang["seoPumperfilmTitle"]}' >{$this->ipsclass->lang['film_title']}</a> &raquo; <span>{$module_title}</span>";
        $page['pathWay']= $this->ipsclass->compiled_templates['skin_film']->load_pathway_module($link);
        $this->output .=  $this->ipsclass->compiled_templates['skin_film']->show_media_page($page);
    }
    function showDetailPage(){
        require_once( ROOT_PATH . "sources/portal_plugins/recent_topics.php" );
        $this->recent_topic = new ppi_recent_topics();
        $this->recent_topic->ipsclass =& $this->ipsclass;
        $topic_id = intval(trim($this->ipsclass->input['id']));
        //var_dump($this->ipsclass->input['id']);exit();
        $where = "t.tid = " . $topic_id . " and t.approved = 1"; // and post <> 0
        $this->ipsclass->DB->flush_query();
        $this->ipsclass->DB->build_query( array( 'select'   => 'p.*',
                                                 'from'     => array( 'posts' => 'p' ),
                                                 'where'    => $where,
                                                 'limit'         => array(0, 1),
                                                 'add_join' => array(0 => array(
                                                                                 'select'=>'t.*',
                                                                                 'from'   => array( 'topics' => 't' ),
                                                                                 'where'    => 'p.topic_id = t.tid',
                                                                                 'type'   => 'left'
                                                                                ),
                                                                      1 => array( 'select' => 'f.*',
                                                                                      'from'   => array( 'forums' => 'f' ),
                                                                                      'where'  => 'f.id=t.forum_id',
                                                                                      'type'   => 'left' ))
                                                )

            );
        
        $this->ipsclass->DB->exec_query();	
        $page = $this->ipsclass->DB->fetch_row();
        //var_dump($page);exit();
        $page['rewrite_title'] = $this->common->filter_title($page['title']);
        $page['rewrite_name'] = $this->common->filter_title($page['name']);
        $page['post'] = preg_replace("#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1", $page['post']);
        
        if ($page['topic_hasattach']) {                    
                    $page['post'] = $this->class_attach->render_attachments($page['post'], $this->attach_pids);
        }
        $page['start_date']=$this->ipsclass->get_date($page['start_date'],"LONG");
        $this->output .= $this->ipsclass->compiled_templates['skin_film']->show_detail_page($page);
        unset ($page);
  
    }
    
   
    function init(){
        $this->ipsclass->load_language('lang_global');
        $this->ipsclass->load_language('lang_regportal');
        $this->ipsclass->load_template('skin_film');
        $this->ipsclass->load_language('lang_film');
        $this->act = $this->ipsclass->input["act"];
        $this->code = $this->ipsclass->input["CODE"];
        $this->hotPerPage = 2;
        $this->defaultPerPage = 2;
    }
    
    /*
     * end load page
     */
}
?>
